#include <glib.h>

static void _inner_glob_asterisk(const char *pattern, const char *string)
{
    GPatternSpec *pspec = NULL;
    gboolean r = FALSE;

    if( (NULL == pattern) || (NULL == string) ) {
        g_print("input param is NULL \n");
        return;
    }

    pspec = g_pattern_spec_new(pattern);

    r = g_pattern_match_string(pspec, string);
    g_print("%s %s match %s \n", pattern, r?"is":"not", string);

    g_pattern_spec_free(pspec);

    return;
}

static void test_glob_asterisk(void)
{
    _inner_glob_asterisk("a*", "abcd");
    _inner_glob_asterisk("ab*", "abcd");
    _inner_glob_asterisk("ac*", "abcd");
    _inner_glob_asterisk("*b*", "abcd");
    _inner_glob_asterisk("abc*", "abcd");
    _inner_glob_asterisk("ab*d", "abcd");
    _inner_glob_asterisk("abcd*", "abcd");

    return;
}

gint main(gint argc, gchar **argv)
{
    g_test_init(&argc, &argv, NULL);

    g_test_add_func ("/glob/asterisk", test_glob_asterisk);

    return g_test_run();
}